#!/bin/bash

MAIN_MK=build/core/main.mk                                                                                                                                               

while true                                                                                                                                                           
do                                                                                                                                                                   
    if [ -f $MAIN_MK ]                                                                                                                                               
    then                                                                                                                                                             
        echo "$(pwd)"                                                                                                                                                
        break                                                                                                                                                        
    else                                                                                                                                                             
        cd ..                                                                                                                                                        
        if [ $(pwd) == '/' ]                                                                                                                                         
        then                                                                                                                                                         
            echo '/'                                                                                                                                                 
            exit                                                                                                                                                     
        fi                                                                                                                                                           
    fi                                                                                                                                                               
done                                                                                                                                                                 
